a.Assign the color ‘burlywood4’
b.Assign the x-axis label to be “Payment Method”
c.Assign the title to be “Bar-Plot for Payment Method”
plot(churn$PaymentMethod, xlab="Payment Method", main="Bar-Plot for Payment Method", col="burlywood4")
Assign the color ‘forestgreen’
Assign the x-axis label to be “Total Charges”
Assign the title to be “Histogram for Total Charges”
hist(churn$TotalCharges, xlab="Total Charges", main="Histogram for Total Charges", col="forestgreen")
Assign the color ‘maroon’
Assign the x-axis label to be “Total Charges”
Assign the title to be “Density plot for Total Charges”
hist(churn$TotalCharges, freq = F, xlab="Total Charges", xlim = c(0,9000), main="Density for Total Charges", col="maroon")
plot(density(churn$TotalCharges), xlab="Total Charges",xlim = c(0,9000), main="Density for Total Charges", col="maroon",lwd=2)
Assign the fill color to be ‘mediumspringgreen’
Assign the boundary color to be ‘azure’
Change the number of bins to be 100
hist(churn$tenure, xlab="Tenure",
main="Histogram for Tenure", col="mediumspringgreen", border="azure", breaks = 100 )
ggplot(churn, aes(x=MonthlyCharges, fill=PaymentMethod)) +
geom_histogram() +
labs(x = "Monthly Charges", title ="Monthly charges by Payment Method")
ggplot(churn, aes(x=MonthlyCharges, fill=OnlineBackup)) +
geom_histogram() +
labs(x = "Monthly Charges", title ="Monthly charges by Online Backup")
ggplot(churn, aes(x=TotalCharges, fill=gender)) +
geom_histogram() +
labs(x = "Total Charges", title ="Total charges by Gender")
ggplot(churn, aes(x=TotalCharges, fill=InternetService)) +
geom_histogram() +
labs(x = "Total Charges", title ="Monthly charges by Internet Service")
1. Build a bar-plot for the ‘PhoneService’ column
Assign the fill color to be ‘pink’
Assign the boundary color to be ‘peru’
ggplot(churn,aes(x=PhoneService))+
geom_bar(fill="pink", color="peru")
Assign ‘InternetService’ to the fill aesthetic
Assign ‘Contract’ to the fill aesthetic
Change the position of bars to ‘identity’
ggplot(churn,aes(x=InternetService,fill=churn$Contract))+
labs(fill="Internet Service")+
geom_bar(position="identity", alpha=0.4 )
ggplot(churn,aes(x=TechSupport,fill=Churn))+
labs(fill="Churn")+
geom_bar()
ggplot(churn,aes(y=TotalCharges, x=tenure))+
labs(x="Tenure", y="Total Charges") +
geom_point(col="wheat3")
ggplot(churn,aes(y=TotalCharges, x=tenure, col=PaymentMethod))+
labs(x="Tenure", y="Total Charges", color="Payment Method") +
geom_point()
ggplot(churn,aes(y=TotalCharges, x=tenure, col=gender))+
labs(x="Tenure", y="Total Charges", color="Gender") +
geom_point()
ggplot(churn,aes(y=TotalCharges, x=tenure, col=Dependents, shape=Dependents))+
labs(x="Tenure", y="Total Charges", color="Dependents") +
geom_point()
Assign it the color ‘yellowgreen’
Use ‘col’ as an aesthetic and Map ‘InternetService’ to col
Use ‘col’ as an aesthetic and Map ‘Contract’
ggplot(churn,aes(y=MonthlyCharges, x=tenure))+
labs(x="Tenure", y="Monthly Charges") +
geom_point(col="yellowgreen")
ggplot(churn,aes(y=MonthlyCharges, x=tenure, col=InternetService))+
labs(x="Tenure", y="Monthly Charges",color="Internet Service") +
geom_point()
ggplot(churn,aes(y=MonthlyCharges, x=tenure, col=Contract))+
labs(x="Tenure", y="Monthly Charges",color="Contract") +
geom_point()
Q8_1. Build a box-plot between ‘tenure’ & ‘Partner’. Map ‘tenure’ to the y-axis & ‘Partner’ to the ‘x-axis’
Assign it a fill color of ‘violet’
Assign it a boundary color of ‘snow3’
ggplot(churn,aes(x=Partner, y=tenure))+
labs(x="Partner", y="Tenure") +
geom_boxplot(fill="violet", col="snow3")
Q8_2. Build a box-plot between ‘tenure’ & ‘MultipleLines’. Map ‘tenure’ to the y-axis & ‘MultipleLines’ to the ‘x-axis’
Assign ‘Partner’ to the fill aesthetic
Assign ‘PhoneService’ to the fill aesthetic
ggplot(churn,aes(x=MultipleLines, y=tenure, fill=Partner))+
labs(x="Multiple Lines", y="Tenure", fill="Partner") +
geom_boxplot()
ggplot(churn,aes(x=MultipleLines, y=tenure, fill=PhoneService))+
labs(x="Multiple Lines", y="Tenure", fill="Phone Service") +
geom_boxplot()
Q8_3. Build a box-plot between ‘tenure’ & ‘Contract’
Assign ‘InternetService’ to the fill aesthetic
Assign ‘PaymentMethod’ to the fill aesthetic
ggplot(churn,aes(x=Contract, y=tenure, fill=InternetService))+
labs(x="Contract", y="Tenure", fill="Internet Service") +
geom_boxplot()
ggplot(churn,aes(x=Contract, y=tenure, fill=PaymentMethod))+
labs(x="Contract", y="Tenure", fill="Payment Method") +
geom_boxplot()
ggplot(churn,aes(x=MultipleLines, y=tenure, fill=InternetService))+
labs(x="Multiple Lines", y="Tenure", fill="Internet Service") +
geom_boxplot()+
facet_wrap(~InternetService)
ggplot(churn,aes(y=TotalCharges, x=tenure, col=Contract))+
labs(x="Tenure", y="Total Charges", color="Contract") +
geom_point()+
facet_wrap(~Contract)
ggplot(churn, aes(x=MonthlyCharges, fill=PaymentMethod)) +
geom_histogram() +
labs(x = "Monthly Charges", title ="Monthly charges by Payment Method")+
facet_wrap(~PaymentMethod)
ggplot(churn,aes(x=gender))+
labs(x="Gender")+
geom_bar(fill="blue")+
theme(
panel.background = element_rect(fill="chartreuse4"),
plot.background = element_rect(fill="cornsilk4")
)
Add a title to the plot ‘Tenure vs Monthly Charges’
Give the panel a background color of ‘coral2’
Give the plot a background color of ‘beige’
Center align the title & make the color of the title to be red
ggplot(churn,aes(x=MonthlyCharges, y=tenure))+
labs(y="Tenure", x="Monthly Charges", title="Tenure vs Monthly Charges") +
geom_point(col="yellowgreen")+
theme(
panel.background = element_rect(fill="coral2"),
plot.background = element_rect(fill="beige"),
plot.title = element_text(hjust = 0.5, colour = "red"),
)